<template>
	<div>
		<el-form :model="formData" :rules="rules" ref="formData" label-width="100px" class="demo-ruleForm">
			<el-form-item label="ip" prop="IP">
				<el-input v-model="formData.IP"></el-input>
			</el-form-item>
			<el-form-item label="日志文件" prop="LOGNAME">
				<el-input v-model="formData.LOGNAME"></el-input>
			</el-form-item>
			<el-form-item label="备注" prop="REMARK">
				<el-input v-model="formData.REMARK"></el-input>
			</el-form-item>
			<el-form-item label="监控状态" v-if="isopen == '添加'" prop="STATUS">

				<!-- <el-switch
					v-model="STATUS"
					active-color="#13ce66"
					inactive-color="#ff4949"
				>
				</el-switch> -->

				<el-radio-group v-model="STATUS" size="medium" :fill="STATUS == 'y' ? '#67C23A':'#F56C6C'">
					<el-radio-button key="y" label="y">开启</el-radio-button>
					<el-radio-button key="n" label="n">关闭</el-radio-button>
				</el-radio-group>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		props: {
			formData: null,
			isopen: null
		},
		computed: {
			STATUS: {
				get: function() {
					return this.formData.STATUS === 1 ? 'y' : 'n';
				},
				set: function(value) {
					this.formData.STATUS = value === 'y' ? 1 : 0;
				},
			},
		},

		data() {
			return {
				rules: {
					IP: [{
							required: true,
							message: '请输入IP',
							trigger: 'blur',
						},
						{
							pattern: /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/,
							message: '请输入正确的IP',
						}
					],
					LOGNAME: [{
						required: true,
						message: '请输入日志文件',
						trigger: 'blur',
					}, ],
				},
			};
		},
	};
</script>

<style></style>
